
import org.activiti.engine.delegate.*;

public class CalculareSuma implements JavaDelegate{
	
	public void execute(DelegateExecution execution) throws Exception{
		String destinatie = (String) execution.getVariable("sosire");
		int numarAdulti =  (Integer) execution.getVariable("nrAdulti");
		int numarCopii =  (Integer) execution.getVariable("nrCopii");
		System.out.println("Calcularea sumei aferente rezervarii");
		int suma = 0;
		if("Paris".equalsIgnoreCase(destinatie)) {
			suma = numarAdulti * 300 + numarCopii * 150;
		}
		else {
			if ("Londra".equalsIgnoreCase(destinatie)) {
				suma = numarAdulti * 200 + numarCopii * 100;
			}
			else {
				if ("Berlin".equalsIgnoreCase(destinatie)) {
					suma = numarAdulti * 220 + numarCopii * 110;
				}
				else {
					if ("Amsterdam".equalsIgnoreCase(destinatie)) {
						suma = numarAdulti * 260 + numarCopii * 130;
					}
					else {
						if ("Madrid".equalsIgnoreCase(destinatie)) {
							suma = numarAdulti * 260 + numarCopii * 130;
					}
						else {
							if ("Roma".equalsIgnoreCase(destinatie)) {
								suma = numarAdulti * 180 + numarCopii * 90;
						}
				}
			}
		}
		
	}
}
		System.out.println("Suma totala este " + suma);
		execution.setVariable ("suma", suma);
}
}
